Giter Site home page Giter Site logo

Faster initialization about desktopamp HOT 6 CLOSED

paulirish avatar paulirish commented on June 22, 2024
Faster initialization

from desktopamp.

Comments (6)

edlea avatar edlea commented on June 22, 2024

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.

paulirish avatar paulirish commented on June 22, 2024

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.

edlea avatar edlea commented on June 22, 2024

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.

edlea avatar edlea commented on June 22, 2024

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.

paulirish avatar paulirish commented on June 22, 2024

ah, can confirm:
image

from desktopamp.

paulirish avatar paulirish commented on June 22, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.