javascript performance measure – Which “href” value should I use for JavaScript links, “#” or “javascript:void(0)”?

Here are two ways you can build a link which runs JavaScript code. Which method is more efficient in terms functionality, page loading speed, validation, and so on? Which one is better, in terms of functionality, page load speed, validation purposes etc.

function myJsFunc() {
    alert("myJsFunc");
}
<a href="#" onclick="myJsFunc();">Run JavaScript Code</a>
function myJsFunc() {
    alert("myJsFunc");
}
 <a href="javascript:void(0)" onclick="myJsFunc();">Run JavaScript Code</a>

These are the things I use

<a href="javascript:;" onclick="myJsFunc();">Link</a>
<a href="javascript:void(0);" onclick="myJsFunc();">Link</a>
<a href="/gracefully/degrading/url/with/same/functionality.ext" class="some-selector">For great justice</a>
$(function() {
    $(".some-selector").click(myJsFunc);
});

I go to the gym almost every day.

<a href="javascript:;" onclick="yourFunction()">Link description</a>

 

How Lack of Rest Can Impact Your Finances Small Businesses Can Enhance File Management Following these Tips How Much Do Real Estate Agents Spend on Marketing? How to Engage Your Online Audience for Long-Lasting Success Why is Plagiarism Such a Big Deal? Resume Service Review: Why Everyone Should Use It
adbanner