Skip to main content

How to Add Custom JavaScript into Your WordPress Site? Neeraj Mishra The Crazy Programmer

When you want to change the theme of your site, one thing that needs to be done is to add custom JavaScript to it. However, there are other options available if you do not want to add it to your site. For instance, simply add the ‘Heat and Footer Script’ as an option which is much less intrusive compared to the other.

Well, this article is not about the various alternatives, but mainly about the JavaScript which can be added to your WordPress site. How you can exactly do the task? We will share the details with you in the section below.

Options to add JavaScript to WordPress Site

How to Add Custom JavaScript into Your WordPress Site

Image Source

It is not difficult to add custom JavaScript to a WordPress site. All you need to know the way through which it can be done. Two main options and ways in which you can add JavaScript to WordPress sites include the following:

1. Add Custom JavaScript File

First of all, you have to save the file with .js format. After this, you may add this into the folder http://wp-content/themes/your-theme/js/. When you do this, go to the settings where there will be two options in front of you. Either you can add it to the header, or the footer. This is how simple it can be.

2. Add Custom JavaScript Without File

This option is simple to add the custom JavaScript without file. You do not need to save this file as .js format. Rather, you can directly upload it to the folder http://wp-content/themes/your-theme/js/. The header will be the place where you will add it and then go to the save setting when you complete the process.

One Thing You Should Never Do

Although it is quite clear that a much better option to add the custom JavaScript to your WordPress site is to use the ‘SCRIPT’ tag. This is added directly into either header or footer.php. However, you should never do that. As WordPress has a specific loading sequence, therefore, this sequence needs to be respected, and this option must not be availed.

The reason behind this is that if you will add to the header or footer.php which will lead to changes within the whole theme. The core and plugins of WordPress might also face conflicts due to the addition of custom JavaScript in this way. Instead of this option that brings so many issues in your WordPress site, therefore, try to use only the above-mentioned two options. Make sure that you do not add it to the header or footer, even if it seems the only option.

When it comes to importing templates, getting a reliable WordPress website builder will allow you to import templates for just about any topic or any niche with endless customization options.

Conclusion

As you can see that the custom JavaScript is not difficult to add to the WordPress site. It will take a few minutes if you know how to do it. We have explained the information in detail where you will get to know about each point. Follow the step by step, and do not make amendments on your own.

The post How to Add Custom JavaScript into Your WordPress Site? appeared first on The Crazy Programmer.



from The Crazy Programmer https://ift.tt/3ejkP4q

Comments

Popular posts from this blog

Difference between Web Designer and Web Developer Neeraj Mishra The Crazy Programmer

Have you ever wondered about the distinctions between web developers’ and web designers’ duties and obligations? You’re not alone! Many people have trouble distinguishing between these two. Although they collaborate to publish new websites on the internet, web developers and web designers play very different roles. To put these job possibilities into perspective, consider the construction of a house. To create a vision for the house, including the visual components, the space planning and layout, the materials, and the overall appearance and sense of the space, you need an architect. That said, to translate an idea into a building, you need construction professionals to take those architectural drawings and put them into practice. Image Source In a similar vein, web development and design work together to create websites. Let’s examine the major responsibilities and distinctions between web developers and web designers. Let’s get going, shall we? What Does a Web Designer Do?

A guide to data integration tools

CData Software is a leader in data access and connectivity solutions. It specializes in the development of data drivers and data access technologies for real-time access to online or on-premise applications, databases and web APIs. The company is focused on bringing data connectivity capabilities natively into tools organizations already use. It also features ETL/ELT solutions, enterprise connectors, and data visualization. Matillion ’s data transformation software empowers customers to extract data from a wide number of sources, load it into their chosen cloud data warehouse (CDW) and transform that data from its siloed source state, into analytics-ready insights – prepared for advanced analytics, machine learning, and artificial intelligence use cases. Only Matillion is purpose-built for Snowflake, Amazon Redshift, Google BigQuery, and Microsoft Azure, enabling businesses to achieve new levels of simplicity, speed, scale, and savings. Trusted by companies of all sizes to meet

2022: The year of hybrid work

Remote work was once considered a luxury to many, but in 2020, it became a necessity for a large portion of the workforce, as the scary and unknown COVID-19 virus sickened and even took the lives of so many people around the world.  Some workers were able to thrive in a remote setting, while others felt isolated and struggled to keep up a balance between their work and home lives. Last year saw the availability of life-saving vaccines, so companies were able to start having the conversation about what to do next. Should they keep everyone remote? Should they go back to working in the office full time? Or should they do something in between? Enter hybrid work, which offers a mix of the two. A Fall 2021 study conducted by Google revealed that over 75% of survey respondents expect hybrid work to become a standard practice within their organization within the next three years.  Thus, two years after the world abruptly shifted to widespread adoption of remote work, we are declaring 20