Comments (6)
This is a great suggestion. I've just push an update (to Github and the CWS) that does this.
I wasn't familiar with mutationObserver. I was hoping to be able to call disconnect() on the observer but couldn't find a good place to do it. It seems that the doesn't get updated in a single set of mutations before the . Hopefully there won't be a noticeable performance impact of keeping the observer alive.
from desktopamp.
nice!
i think we can disconnect it.
https://jsbin.com/hureme/1/edit?html,output has the flow. basically disconnect when we hit the <body>
element.
also you can probably flip attributes
to false
.
from desktopamp.
I was sure I'd tried that, but you're absolutely right. I'll test on a few more sites and push.
The attributes
flag makes sense too - I added that thinking it was needed to detect the ⚡️attribute on AMP pages (to force a max-width) but that will always be part of the original <html>
mutation I think.
Thanks for the guidance. Much appreciated.
from desktopamp.
I think I spoke too soon. On The Verge (e.g. http://www.theverge.com/2015/10/21/9556153/internet-of-things-privacy-paranoia-data-volkswagen-scandal) it seems that the <head>
is still being mutated when the <body>
starts to be mutated.
On that page, there's a lot of <script>
tags before our <link>
. Possibly an optimisation to start parsing the <body>
rather than blocking on the <head>
while the JavaScript interpreter does its thing?
I've pushed SHA: 8a7dd0d that has the check and disconnect code in. It works on some sites, just not all.
from desktopamp.
from desktopamp.
meta before the end is ours.
and <script src="https://cdn0.vox-cdn.com/javascripts/verge2_head.v6b1e078fb1d0829b.js"></script>
is what makes the <body>
from desktopamp.
Related Issues (13)
- Toggle to switch back to desktop version HOT 5
- Link to github from chrome extension HOT 1
- Set max-width on desktop HOT 3
- Seems to mess with back button on The Verge HOT 1
- Setting max-width doesn't always work correctly. HOT 2
- License? HOT 1
- Infinite Loading Loop for poorly developed websites HOT 10
- Add Ability To Blacklist Domains/URL Paths HOT 1
- Consider removing applyMobileCSS?
- Consider sending text/html accept header? HOT 1
- Doesn't work on reuters.com
- Add default zoom per AMP domain
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from desktopamp.