Topic Closed
Furukoo
9 Posts

Hello

I search in the 'gpOutput::GetHead();' function to desabled the parsing of combined javascript.

Then i want to defer parsing in the end of the html document just before </body>

 

someone can said me where is the output function for javascript ?

Thanks

6 years ago#6272

Josh S.
2K Posts
266K Downloads
16 Themes
18 Plugins

Sorry to say, gpEasy does not have an option for outputing the javascript at the end of the document.

6 years ago#6274

Stano
483 Posts
16.6K Downloads
1 Themes
1 Plugins

Hello Furuko,

can you describe a bit closer the issue? What's a purpose for moving all javascripts to the end of document/template?

Edited: 6 years ago#6275

Furukoo
9 Posts
Here some recommandation from Google Page Speed

 

Details from Google

There are several techniques that can be used to defer parsing of JavaScript. The simplest and preferred technique is to simply Defer loading of JavaScript until it is needed. A second technique is to use the <script async> attribute where appropriate, which prevents parsing from blocking the initial page load by deferring it until the browser's UI thread is not busy doing something else. If neither of these techniques is suitable, there are some additional techniques commonly used in mobile applications, described below:

When building mobile applications, it can be necessary to load all of the JavaScript needed by an application up front, so the application can continue to work when the user is offline. In this case, some applications, such as mobile Gmail, find it useful to load JavaScript in comments and later eval() the JavaScript when it is needed. This approach guarantees that all JavaScript is loaded during the initial page load, while not requiring that JavaScript to be parsed.

An alternative to storing code in comments is storing code in JavaScript string literals. When using this technique, the JavaScript is only parsed when needed, again by callingeval() on the string literal. This technique also allows an application to load JavaScript early, but defer parsing until it is needed.

Note that moving your '<script>' tags to the end of the page is sub-optimal, since the browser will continue to show a busy indicator until the page has finished parsing this JavaScript. Users may wait until the page load indicator shows that the page load is complete before interacting with the page, so it is important to load JavaScript in a way that minimizes the time it takes for the browser to indicate that the page load is complete.

In our own tests conducted in early 2011, we found that on modern mobile devices, each additional kilobyte of JavaScript adds about 1ms of parse time to the overall page load time. So 100kB of JavaScript included in the initial page load would add 100ms of load time for your users. Because JavaScript must be parsed on every visit to a page, this added load time will be part of every page load, whether loaded from the network, via the browser cache, or in HTML5 offline mode.

https://developers.google.com/speed/docs/best-practices/mobile

Pehaps someone can make a plugin ?

Edited: 6 years ago#6277

Stano
483 Posts
16.6K Downloads
1 Themes
1 Plugins

Maybe this could be done with a combination of some gpEasy action-hook (called after the full page is assembled) and by using PHP's DOMdocument class as shown here. But there can be problem, if the page's body contains some script that depends on another script which should be already defined in head tag, something like jQuery(function(){...}); or similar, then such a code won't work. Imo it seems to be a non trivial problem.

Edited: 6 years ago#6278

Eric
193 Posts
1.4K Downloads
1 Themes

I have read and tried the recommendations of putting the scripts at the bottom, and ran into the same problems Stano describes. For example, if you use jQuery to collapse an accordion menu:

  • with scripts at the bottom, all menus will be expanded when the page draws and collapse after the scripts have loaded, causing an annoying flash.
  • with scripts at the top, it will take a touch longer to load the page but when it displays, it will be in a finished state.

There are ways around that specific problem, but I think it will be hard to get all the plugins to work with scripts at the end. In the best case scenario, we could get some scripts to load at the top and some at the bottom, but identifying them may be hard.

6 years ago#6281

Topic Closed

 

News

Typesetter 5.1
8/12/2017

Typesetter 5.0.1 is now available for download. 5.1 includes bug fixes, UI/UX improvements, ... Read More

Over 8 Times Faster Than Wordpress
5/3/2016

We've known for a long time that Typesetter is fast. It's something we take pride ... Read More

More News

creisi productions

Dienstleistungen von creisi productions, Luzern (Schweiz): * Konzeption, Planung und Erstellung Ihres Internet-Auftritts * Betreuung und Aktualisierung/Pflege Ihrer Website * ...

Find out more about our Provider Spotlight

Log In

  Register