How to Correctly Add JavaScript codes in Blogger?

While adding JavaScripts codes in Blogger template editor, we often face some weird XML Errors like Error parsing XML, line 768, column 20: The content of elements must consist of well-formed character data or markup. These sorts of errors occur when a JavaScript code is not well formed, or the codes are not written correctly by the developer.  Recently, one of our users asked us How to Correctly Add JavaScript Codes in Blogger?  This tutorial will turn out to be useful for those who are just starting to learn Blogger template and plugin development. In this article, we will show you How to Correctly Add JavaScript codes in Blogger?

The Blunder :

Before installing any new codes in his template a person should make sure that the script or style tags are properly closed. Most of the times you forget to copy the ending script tag, and in the end ultimately it shows errors.  For those who don’t know a lot they use codes like this:

jQuery(document).ready(function($) {

Here, it can clearly be seen that the <script> tag is not followed by a proper closing </script> tag which is wrong. The correct technique is to close the tags properly, like we do in simple HTML.  Let's go ahead and look at the right way of doing it.

How to Correctly Add JavaScript codes in Blogger?

Adding Scripts in Blogger is extremely straightforward. All you need to do is to go to >> Your site >> Template >> Edit HTML. Now it depends on you where you would like to paste your JavaScript coding. However, we prefer you to add it above the </head> tag because this is the place where all technical things are present. Here’s how the code would look like:

<script type='text/javascript'>
Your JavaScript coding here

Once the script is correctly added in your template hit the “Save Template” button, and this you would not face any errors. Which means that the JavaScript is correctly added in your blogger template.

We hope this tutorial has helped you in learning how to properly add javascript codes in blogger. Let us know about your experience? In case you have faced such errors too. Feel free to leave any error below that you are facing while adding new codes to your template. 

The Editorial Team of MyBloggerLab consists of a group of Professional Blogger geeks Led by Syed Faizan Ali (Founder of MyBloggerLab).

Comment With:
Choose Wisely!


August 12, 2013 at 12:51 PM

What A Post Dear You're Doing Fabulous Job In Your Blogging Carrier Hope You Will Be A World Class Blogger In Future

August 13, 2013 at 10:14 AM

Happy to know that you were listed as a top Pakistani Blogger !
And this is a mistake which som many widget makers make !
They do not close tags properly and we have to close it !

As a fan of My Blogger Lab - I request you to start publishing widgets here again!
We know that your widgets are of top quality !
We still want your widgets ! Please start sharing awesome widgets again !

Rizwan @ Blogger Kid

August 15, 2013 at 1:20 AM

great one but unfortunately I left blogger and started wordpress just because I found too much difficulties but reason could be I am a poor developer and don't know much of scripting.

August 17, 2013 at 10:23 AM

its awesome

October 25, 2013 at 12:22 PM

I have uploaded Javascript in Dropbox, Now I want to use the link address and use it in blogger to make length of code lesser. Is there any way ?

Editorial Team MOD
October 27, 2013 at 4:34 PM

Are you uploading files to Public folder? If yes you can left click on it "View Public URL" Thats done

January 13, 2014 at 10:39 PM

Thank you so much!
Very useful.
You fix my problem Sir..

August 28, 2014 at 12:37 PM

I have developed an application using java script. I have copied that code and pasted in blog editor.

That application is not working properly.

December 28, 2014 at 12:55 PM

The problem, and why this doesn't work is because in the code there is two "&&" which apparently does not belong and is causing an error.

January 8, 2016 at 9:12 AM

for sure i am very grateful to this post

March 5, 2016 at 8:01 AM

This blog awesome and i learn a lot about programming from here.The best thing about this blog is that you doing from beginning to experts level.

Love from

April 1, 2016 at 6:13 PM

Thank you. It's really helpful.

June 28, 2016 at 9:23 AM

Such A great Work For Blogging and Nice One Keep It Up Dear Faizan

July 19, 2016 at 9:46 AM

This one really helps. I got also problem with rendering then I follow this to implement on my blog Thanks a lot!

Editorial Team MOD
July 26, 2016 at 11:36 PM

I am glad it worked for you. Cheers

Post a Comment

We’re eager to see your comment. However, Please Keep in mind that all comments are moderated manually by our human reviewers according to our comment policy, and all the links are nofollow. Using Keywords in the name field area is forbidden. Let’s enjoy a personal and evocative conversation.

Helping You to do Cool Things With Blogger Since 2012™.

© Copyright 2012 - 2016. MBL Networks, All Rights are Strictly Reserved.