# How to insert a script tag into head element using jQuery?

**URL:** <https://forum.kirupa.com/t/how-to-insert-a-script-tag-into-head-element-using-jquery/326416>\
**Category:** web dev\
**Created:** [December 13, 2011, 4:37am UTC](https://forum.kirupa.com/t/how-to-insert-a-script-tag-into-head-element-using-jquery/326416 "2011-12-13T04:37:05Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![kadaj](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/kadaj/32/9061_2.png) [@kadaj](https://forum.kirupa.com/u/kadaj)\
**Post date:** [December 13, 2011, 4:37am UTC](https://forum.kirupa.com/t/how-to-insert-a-script-tag-into-head-element-using-jquery/326416/1 "2011-12-13T04:37:05Z")

</div>

Hi,  
Is it possible to insert a script tag to a head element of an html file using jQuery? I tried a couple of methods, but none worked. I don’t see the script but the script is getting executed.  
But I’m able to do it using plane javascript and dom.

Eg:  
using jQuery

```auto

$(document).ready(function() {
    $('<script type="text/javascript">alert("hi - appendTo");</script>').appendTo('head');
    $('head').append('<script type="text/javascript">alert("hello append");</script>');
});
// gets the alert, but I don't see the appended script tags in elements (chrome dev tools)

```

Other tags like div shows up.

Thanks.
