0

I am using the Google visualization for drawing graphs into my website. This involves a lod of java script.

 <script type="text/javascript" src="http://www.google.com/jsapi"></script>
 <script type="text/javascript">
 google.load('visualization', '1', {packages: ['annotatedtimeline']});
 </script>

These two lines of script takes at least 5 to 8 sec to load initially. How ever i use the graph feature in my website after sometime of the initial page load and not immediately. So i was wondering instead of slowing down the page load by 5 sex for the script to load can i do a lazy load of java script parallel to my page load. This will make my initial page load faster. Can this be done, if so please let me know syntax and also some link providing the documentation if any.

3 Answers 3

2

Put all the script tags immediately before the closing body tag as per this YSlow recommendation.

Sign up to request clarification or add additional context in comments.

2 Comments

Some of the on load scripts do not get executed untill the above scripts are loaded. This causes some UI problems on my page.
@vinodtiru, you can try to put all your SCRIPT tags in the right order before the BODY end tag, and remove the onload handling.
0

Put it as lower as you can at the page, meaning closer to the end tag. Your page will load all its contents before delaying further to load the JS.

Comments

0

You can also experiment with the DEFER attribute and placing the script tag into a separate head tag:

http://www.hunlock.com/blogs/Deferred_Javascript

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.