Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Author hoffcamp

    (@hoffcamp)

    Hey, thanks for the suggestion. You are right, most of the JS that is currently echoed with the HTML could me moved into the userscripts.js file, but unfortunately some of it is generated dynamically according to the form structure. Is there a way to get around this? My concern is that if I generate a special scripts file for each form that the browser will indeed cache it and not load new ones as people are playing with changes to their forms. Any suggestions?

    Thread Starter Nicolas Bouliane

    (@n1c0_ds)

    I am not very familiar with javascript in WordPress, but you could always create a javascript.php file that contains it (changing the headers to match the content type). This way it wouldn’t produce validation errors with the XHTML doctype. Otherwise, you should at least wrap them in CDATA tags (see previous link) so they work properly with XHTML, since it’s the official WordPress doctype.

    You should also avoid displaying javascript on pages where there are no forms if possible.

    These links might help:
    https://inchoo.net/wordpress/creating-wordpress-plug-in-that-shows-locations-of-current-users-based-on-xml-data-using-dynamically-created-javascript-in-header-of-the-page-and-google-api/

    Plugin Author hoffcamp

    (@hoffcamp)

    Thanks. This might take some time to do correctly / test.

    Plugin Author hoffcamp

    (@hoffcamp)

    For 1.5.13 I moved most of the scripts to userscripts.js. The file is only 8kb, and since I would have to scan the post(s) being loaded for the form shortcode to know if it was being used or not I figured it wasn’t worth doubling the database traffic for each page load over.

    The dynamically generated scripts I wrapped as a CDATA section, and these only appear on pages with a form, unlike before.

    Thanks for pointing this out – I took the time to validate the output as HTML5 and cleaned up some other things.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘[Plugin: WordPress Form Manager] XHTML validation and external JavaScript’ is closed to new replies.