Usage of HTML in Javascript Files


I’m currently developing a WP theme for themeforest and I wonder if it would be a problem for approval if I use HTML in Javascript files like this:

My theme using REST API almost everywhere, dealing with HTML with JSON data in Javascript file much easier.

Or Do I need to use clone node method?


Better to find another way to achieve this.

So you think this is looks dirty right? I’m feeling the same.

The another way:

I can create a html in a php file which is totally hidden and I can use clone node in javascript side without including HTML in javascript file.

But there is no performance diffirence and it will make my complex code more harder to work on…

You should be able to manage it without pushing HTML codes into JS. Would be a problem if someone wants to modify it

Hello, thank you for your answer. Yes I’m able to manage it without passing HTML into JS.

I can pass HTML into a PHP file with “template” HTML tag and I can use clone.node method of javascript to use it in JS file.

End of the day, I still need to use html with javascript. Because I’m dealing with JSON data that comes from server side.

But a person can still edit code if it’s in JS file and using HTML directly in JS file is more easier, more comfortable to do it for me.

Can it be cause a rejection problem? If it can, I will turn my code into clone.node method and I will use that HTML code in my PHP file.

Just upload the file as clean as you can create. If it’s related to the JS, you will get a soft-reject instead of hard-reject then you can fix the problems