• Hi, I’m implementing some CDN libraries using a popular method seen here (basically de-register and register):

    http://digwp.com/2009/06/use-google-hosted-javascript-libraries-still-the-right-way/

    It’s working great, but I have a ‘best practices’ question. I simply placed the code in functions.php (of my theme) as suggested.

    So, does WP actually deregister (wp_deregister_script) and re-register (wp_register_script) on each and every page requested from the front end?

    In other words, does code not contained within a function (located in ‘functions.php’) fire for every request?

    If that’s the case, is it smarter to create a function called ‘inject_cdn_scripts()’, for example, and somehow only call that function once upon a WP initialization hook (maybe using add_action)?

    I’m new to WP, coming from a .NET background, so I’m thinking it would be similar to placing this function in global.asax > Application_Start().

    Thanks!

Viewing 1 replies (of 1 total)
  • Thread Starter georgecobb

    (@georgecobb)

    Hi,

    Really hate to bump… Just curious if anyone has any thoughts on this and whether or not I’m even understanding the architecture of functions.php correctly.

    Thanks!

Viewing 1 replies (of 1 total)

The topic ‘Optimizing when to call wp_register_script?’ is closed to new replies.