treehouse : what would you like to learn today?
Web Design Web Development iOS Development

Clean up script tags in WordPress

  • Wordpress outputs scripts like this:

    < script type='text/javascript' src='/path/to/script.js'></script >
    

    Which forces me to instead call scripts directly from the theme, so they appear like this:

    < script src="/path/to/script.js"></script >
    

    I've googled high and low and I can't find anything regarding how to change those single quotes to double quotes and remove the "type" attribute. Any ideas?

  • Isn't it best practice to use wp_enqueue_script ?

  • Yes, but I can't really do that, because that's what creates the outdated markup in the first place.

    And I care about this sort of thing for some reason :P

  • I care about those things too, but don't have experience with WP. Can't you trace the php back to where it actually creates this output and fix it there? (Not the best solution obviously, since updating WP will just overwrite your changes, but don't ask me how to make a module or plugin for WP that overwrites default behavior)

  • You can hard code that in if you wish.

    Just make sure that other plug-ins are not requiring same script.