Lazy Loading swfobject.js
The SWFObject.js file can be lazy loaded.
Google's google.load
If you intend to use Google's cached copy of SWFObject (highly recommended), you can also take advantage of Google's lazy loading tool.
<script type="text/javascript" src="http://www.google.com/jsapi"></script> <script type="text/javascript"> google.load("swfobject", "2.2"); google.setOnLoadCallback(function() { alert(swfobject.hasFlashPlayerVersion("9.0.18")); }); </script>
Google's documentation can give you all the details, but the nitty-gritty is this:
- Load the
jsapi
file - Specify which Google Ajax API file you want to load (in this case SWFObject version 2.2)
- Optional: Specify a function to execute when the SWFObject file has been successfully loaded in your page
Other lazy loading techniques
Frankly, there are too many lazy loading techniques to mention. Excluding the Google example posted above, none are specific to SWFObject, and will work with just about any script file. Ajaxpatterns.org has a great overview of lazy loading.
Questions or Comments?
If you have questions or would like to point out an error, please post your remarks in the SWFObject Google Group. Thanks!