Jump to content

Defer parsing javascript


Recommended Posts

Posted

Good luck!
http://community.invisionpower.com/topic/364174-ipb-search-the-following-search-terms-are-not-allowed-and-were-removed-from-your-query-javascript/

Posted

Hello,

You can use an anonymous function to load the JavaScript, and place it at the bottom of your page. Something like:

(function()

{

	var o = document.createElement('script'); o.type = 'text/javascript'; o.async = true;

	o.src = '/path/to/your/javascript/file.js';

	var a = document.getElementsByTagName('script')[0]; a.parentNode.insertBefore(o, a);

})();



Doing that will defer the loading of that JavaScript until after the page has finished parsing.

That's not always practical though, so you can also use the defer attribute:

http://www.w3schools...cript_defer.asp

Edit: There's a ton of information on Google, notably the following guidelines by Google themselves, inc example(s):

https://developers.g...actices/payload

Hope this helps! :smile:

Posted

How do you edit with defer or async when the line for IPB JavaScript is?:

{parse template="includeJS" group="global" params="$jsModules"}



That one line in globaltemplate is what spits out the list of <script type="text/javascript" src="...

I'm trying now to see if it can be done for the includeJS template.

Posted

Well async gave the same result as moving javascript to footer. Everything worked except for QR and edit boxes. (that I know of)

Edit: Gallery JS does not work also.

Cuts almost 2 seconds! from "first view" page load speed though.

Posted

Well async gave the same result as moving to footers. Everything worked except for GR and edit boxes. (that I know of)




How to use async? Laymen term tutorial please?

I appreciate your help,
Thanks!
Posted

How to use async? Laymen term tutorial please?



I appreciate your help,


Thanks!




Ha! I was thinking the same thing when I read... the above howto.

If I get it to work without breaking anything I will post how to here.
Posted

Hello,



You can use an anonymous function to load the JavaScript, and place it at the bottom of your page. Something like:



(function()

{

	var o = document.createElement('script'); o.type = 'text/javascript'; o.async = true;

	o.src = '/path/to/your/javascript/file.js';

	var a = document.getElementsByTagName('script')[0]; a.parentNode.insertBefore(o, a);

})();



Doing that will defer the loading of that JavaScript until after the page has finished parsing.

That's not always practical though, so you can also use the defer attribute:

http://www.w3schools...cript_defer.asp

Edit: There's a ton of information on Google, notably the following guidelines by Google themselves, inc example(s):

https://developers.g...actices/payload

Hope this helps! :smile:



Not as easy as you think. Implementing this (async) breaks java the same way moving to the footer does. I see you're read topic so I guess you also realize what you posted does not apply easily to IPB;

thanks anyway
Posted

Not as easy as you think. Implementing this (async) breaks java the same way moving to the footer does. I see you're read topic so I guess you also realize what you posted does not apply easily to IPB;



thanks anyway




The OP made no mention of IP.Board, you're making an assumption.
Posted

The OP made no mention of IP.Board, you're making an assumption.




Sorry I thought this forum is about IPB talk and support.. so i didn't thought to mention about it. If you check the link it's fearless-assassins.com and it's running all IPB add-ons.
Posted

Bahaha! Seriously? Maybe he's taking about Wordpress. :thumbsup:




Your sarcasm is very much misplaced.

If you had taken the time to look carefully you'd have noted that this forum is not necessarily IPS-software specific, just look at the other threads - so yeah he could have been talking about Wordpress.

Technically it's in the wrong section anyhow, hehe!

Just so you know in future :smile:

Archived

This topic is now archived and is closed to further replies.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...