The script has always been present in web development. More or less every website has at least some rows of code that is in use. Is JavaScript important? No it is not. A website does not need that script for remaining online.
How do we use the JavaScript and why? Well, websites sometimes need some extra effects or some functions. For example checking if data in a form is correct or creating some moving text. JavaScript is useful both on website and on its admin side. That is, if administrating website is in some kind of content editor then there is JavaScript that manages different operations. And if our website has any dynamic effect then there is JavaScript that takes care of it. Sometimes with PHP.
Programming websites and using JavaScript does not require special way of combining those. In some website the script is written in HTML code and in others it is included by <script> tag. The last mentioned alternative uses e.g. a .js or a .php file for including the script in website. Both methods are good solution if we want to avoid too much and too mixed code at one and same place. They make our web development more profesional. By using our JavaScript in a .php file we get good opportunities to hide and protect our own functions but we also can combine them with PHP.
Nowadays many web developers use different JavaScript frameworks such as React, Angular, Node.js, and Ember.js. Therefore the development becomes easy. The frameworks contain many available functions and developers do not have to create them from scratch.
On the other side there are web developers who prefer to go the hard way. They create own functions and use them instead of using similar functions from different frameworks. If a web developer knows how to work with JavaScript only or together with PHP (Ajax) then the result can be more than satisfying.
It is not required to use JavaScript frameworks to achieve better result but it can facilitate much if the experience with those frameworks is good enough.