# Problem with \<script\> (and closing html tags)

**URL:** <https://forum.pinegrow.com/t/problem-with-script-and-closing-html-tags/4845>\
**Category:** Pinegrow Theme Converter\
**Tags:** bug\
**Created:** [January 16, 2021, 3:09am UTC](https://forum.pinegrow.com/t/problem-with-script-and-closing-html-tags/4845 "2021-01-16T03:09:39Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![sirojuntle](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.pinegrow.com/sirojuntle/32/2328_2.png) [@sirojuntle](https://forum.pinegrow.com/u/sirojuntle)\
**Post date:** [January 16, 2021, 3:09am UTC](https://forum.pinegrow.com/t/problem-with-script-and-closing-html-tags/4845/1 "2021-01-16T03:09:39Z")

</div>

I believe I have found some bugs with `<script>`:

1. The use of `<script>` placed out of `<head></head>` does not work automatically neither manually.  
Cases of use: scripts in the footer and JSON LD  
For other users: My current solution is to do not export the script and place the code manually in function.php after `/* Pinegrow generated Enqueue Styles End */`

2. When using JSON LD, the convert removes the attribute ´type="application/ld+json"´ which will fail to its purpose and also will cause an error in the console - wherever the script is placed.

3. Sometimes the closing tags `</body>` and `</html>` are removed from my html. I noticed more in index.html. Is there any reason for that?  
It makes my javascript to fail when testing the layout

Thanks

---

<div class="post-metadata">

**Author:** ![RobM](https://avatars.discourse-cdn.com/v4/letter/r/278dde/32.png) [@RobM](https://forum.pinegrow.com/u/RobM)\
**Post date:** [January 16, 2021, 3:32pm UTC](https://forum.pinegrow.com/t/problem-with-script-and-closing-html-tags/4845/2 "2021-01-16T15:32:40Z")

</div>

Hey @sirojuntle,  
Me again! Maybe somebody else will have some input.

For point 1 - a couple of points. How are you handling the scripts within Pinegrow. For adding the JSON-LD library, you need to make sure that you are enqueueing the script using the WP actions. This will put it into the functions.php automatically.

 ![image](https://canada1.discourse-cdn.com/flex036/uploads/pinegrow/original/2X/f/f6a891a35cad667ffca97f5008da5475a93b6507.png)  
Here the library script is in my footer being delivered by CDN.  
If you HAVE to put it in manually, it is recommended that you enqueue in the ‘inc/custom.php’ file. That way it doesn’t get overwritten at each export.

For point 2 - If you add the script directly to the page, export will place the script through the functions.php file using ‘wp\_add\_inline\_script’. This doesn’t allow for directly adding a type. Instead you will have to either use a PHP method to add the script, like the [PHP JSON-LD library](https://github.com/digitalbazaar/php-json-ld), or potentially directly echo the script to the page in a PHP block (not sure if echo will handle JSON data correctly.  
I also don’t think that a filter like `script_loader_tag` will work because I don’t think the inline script gets passed with a dynamic tag that can be changed through a filter.

For point 3 - The only times I have seen that happen is when the HTML in the document is malformed.

Just my $.02,  
Bob

---

<div class="post-metadata">

**Author:** ![sirojuntle](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.pinegrow.com/sirojuntle/32/2328_2.png) [@sirojuntle](https://forum.pinegrow.com/u/sirojuntle)\
**Post date:** [January 18, 2021, 3:42pm UTC](https://forum.pinegrow.com/t/problem-with-script-and-closing-html-tags/4845/3 "2021-01-18T15:42:48Z")

</div>

Thank you again, @RobM,

The problem with enqueueing scripts in footer, even when manually adding the Enqueue, it wasn’t adding the script in the footer or it was having problem addin `get_template_directory_uri()` for relative path scripts. But I think I figured it ou with the help of your another answer.

In fact, my HTML was malformed. After I fixed that, it looks like the scripts in footer are working both automatically or manually.

And about JSONLD I think I will end using a SEO plugin for that, but it is nice to know we have a option!

Thank you!
