Should I convert my inline script so I can put it into an external .js file?

Should I convert my inline script so I can put it into an external .js file?

I'm new to jQuery, and I have been using the SnapScroll jQuery plugin by koga73 (<a href="https://github.com/koga73/SnapScroll" target="_blank">https://github.com/koga73/SnapScroll</a>) in my webpage.

I'm new to jQuery, and I have been using the SnapScroll jQuery plugin by koga73 (https://github.com/koga73/SnapScroll) in my webpage.

It has requested me to use the inline script:

<script> 
var snapScroll = $("header, section, footer").SnapScroll({
hashes:true }); console.log(snapScroll);

$("header").on(snapScroll.eventChangeActive, function(evt, newActive){ console.log(evt, newActive); });

$(document).on(snapScroll.eventChangeVisible, function(evt, visibleList){ console.log(evt, visibleList.data); }); </script>

It's been working fine, but I was just wondering is it worth moving it into an external .js file, and if so, how do I convert the code to work in an external .js file?

My external js file is:

<script type="text/javascript" src="web/js/init.js"></script>


javascript jquery html css

Bootstrap 5 Complete Course with Examples

Bootstrap 5 Tutorial - Bootstrap 5 Crash Course for Beginners

Nest.JS Tutorial for Beginners

Hello Vue 3: A First Look at Vue 3 and the Composition API

Building a simple Applications with Vue 3

Deno Crash Course: Explore Deno and Create a full REST API with Deno

How to Build a Real-time Chat App with Deno and WebSockets

Convert HTML to Markdown Online

HTML entity encoder decoder Online

Building a minesweeper game using Javascript, HTML and CSS

In this article, you'll learn how to build minesweeper using JavaScript, HTML and CSS. I also used jQuery, a JavaScript library that is helpful for interacting with html. Whenever you see a function call with a leading dollar sign, that is jQuery at work

Material Login & Signup Form with CSS, HTML and JavaScript

How we can create a login and signup form with the material design using HTML CSS JavaScript? Solution: See this CSS Material Login & Signup Form With jQuery, Material Design Form.

Bar Graphs with Animation using JavaScript, HTML, & CSS

How we can create Bar Graphs With Animation using JavaScript, HTML, & CSS? Solution: JavaScript Animated Bar Graph. In Other Words, Bar Chart With Animation Effects.

Countdown with HTML, CSS, and JavaScript / How to create JavaScript Countdown

Countdown with HTML, CSS, and JavaScript / How to create JavaScript Countdown. W will build a Responsive Website with HTML, CSS, and JavaScript

Creating Price Range Slider using JavaScript, HTML and CSS

How we can create price range slider with minimum and maximum value? Solution: See this Create Price Range Slider using JavaScript, HTML and CSS, Min and Max Price Select.