Proposal for WordPress plugin – customScript

You will only see the demo animation if you click link to this post


For this blog I am using WordPress and I am quite happy with it, but I miss one feature – the ability to add
custom javascript code to given post. I do not want to have separate demo pages when I am want to demostrate
some piece of code or something. Sometimes I need it to modify the Html structure of page, or add a simple
animation or for whatever just crosses my mind:) I’ve tried to write my own wordpress plugin for this, but I don’t have enough time to finish it. I have already
spent three evenings on it. Writing a WP plugin proved to be much more difficult task than I thought it to be.
So I deciced to crowdsource the idea. Hopefully someone will read this and write the plugin 🙂 Anyway, there is a workaround, but it is not very convenient. And it requires access to file system, so it will
not work on hosting.


If you really need to add custom javascript to some Worpress code, use this workaround:

  • install Single Post Template Plugin by Nathan Rice
  • create your own template page for single post
  • it must contain
  • on the first lines:
  • /* Single Post Template: [Descriptive Template Name]
  • Description: This part is optional, but helpful for describing the Post Template */
  • wp_enqueue_script( ‘jquery’ );
  • Write your post
  • Choose the template you have created (see above)
  • Write the Javascript code you wish to run on this post in some editor
  • Minify it.  JSMinifier
  • Switch to HTML view
  • Add <code class=”customscript” style=”display:none;”>Replace-with-your-code</code>
  • Switch back to Visual view
  • Replace text in <code> with your minified javascript code. If you don’t minify it, you risk that WordPress will replace new lines with <br/> and breaks your code.
  • Go to Preview of your post. The javascript code in <code> should run.

Important notice

If your script needs some special HTML structure (as a placeholder or a container – as in my case), make sure you back it up somewhere. WordPress deletes empty html elements on save! Don’t forget that not everything you write in HTML view will actually stay there.


I am looking for someone who will write this WP plugin 🙂 Please.

The moving thing below is created via custom script. I do need a WP plugin for such demos.

PS: The animation is taken from RaphaelJS demos.

One reply on “Proposal for WordPress plugin – customScript”

Comments are closed.