Placing a notification on duplicated JavaScript code

In the past, I've had the displeasure of seeing my sites completely ripped off (front end), with some individuals even going so far as to copy every piece of content, including the GA tracking code :)

I'm considering inserting a hidden notice within the JS code so that if someone copies it, they (and their visitors) will be made aware. While I understand that front end code cannot be fully protected, if this deters even just a few people from using it (especially those who are not tech-savvy), then it's a win.

So far, I have taken the following steps (as recommended by Amy):

  • minified & obfuscated the code
  • added a copyright notice at the top

Here is a small snippet of what I plan to merge into the existing code:

if (window.location.hostname && window.location.hostname !== 'myDomain') {
  document.body.style.opacity = '0.2';
  document.body.style.pointerEvents = 'none';
  c = [84, 104, 105, 115, 32, 105, 115, 32, 97, 32, 114, 105, 112, 112, 101, 100, 32, 115, 105, 116, 101, 33];
  alert(String.fromCharCode.apply(null, c));
}
<p>Lorem ipsum dolor sit amet, his aperiam percipit assueverit ea, sit ei eius adhuc tacimates. Cum ad numquam rationibus, mel eu scripta aliquando. Eum ex habemus constituto mediocritatem. Ea dicam aliquip salutatus usu, vidit admodum sadipscing at mei. Alterum blandit efficiendi duo in, dicat quodsi vidisse in quo, malis latine lucilius ad est. Qui enim explicari at, est cu iusto impetus, ferri iudico similique at eos.</p>

Are there any more unique strategies besides what I already have in place? :)

Answer №1

Your current strategy is essentially setting a timer for trouble and making it easy for unauthorized removal.

Instead:

  1. Add copyright notices to the beginning of your code

  2. Condense your code

  3. Mask your code

You may not be able to entirely prevent theft of your JS code, but you can make it not worth the hassle.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Display or conceal a frame with the help of JavaScript or jQuery

Is there a simple way to hide the "topFrame" and "menu" frames when clicking an image or button, and then unhide them by clicking again? Apologies for not including the "topFrame" and "menu" jsp files, as they are dynamically generated in my application. ...

Issues with the functionality of the sliding menu in Angular are being encountered when trying to use $

Challenge I am facing an issue with a slider menu feature that I integrated into a mobile application for navigation purposes. The menu is functioning properly - it displays, allows flicking of the initial links, and can be closed by pushing the backdrop. ...

Is it possible for an Object.prototype function in Typescript to return an instance of a Sub type?

I'm working on some code that involves defining classes like the following: class Place { next: Place; get to() : Place { return this; } } let places : Place[]= []; .. places[0].to.next = new Place(); Since there are many similar classes, ...

What could be causing my function to not successfully retrieve elements based on their text content?

A function called matchTagAndText is designed to take two arguments: a selector and text, checking if any matched elements contain the specified text. The function code is as follows: function matchTagAndText(sel, txt) { var elements = document.queryS ...

Merging SCSS and CSS into a unified file using WebPack

Trying to grasp webpack as a beginner is proving to be quite challenging for me. I'm struggling with the concept of merging multiple scss and css files together using webpack, after transpiling the sass. Unlike gulp, where I could easily transpile sa ...

execute the execCommand function following an ajax request

I am currently developing a WYSIWYG editor and encountering an issue with image handling using execCommand. Here is a simplified example of my page structure: <div id="buttons_panel"><input id="img_submit" type="button"/></div> <div ...

Understanding the behavior of a React component when passed as a prop

Typically, components are passed down as children to another component. However, I have noticed in some UI libraries that components can also be passed using standard named props. I attempted this approach myself but encountered some limitations without an ...

Revise Bootstrap accordion setup

I currently have a Bootstrap accordion set up on my website using Bootstrap 4.1.0 <div id="accordion" class="mt-3"> <div class="card"> <div class="card-header bg-dark text-white" id="headingOne"> <h5 class="mb-0 f ...

Exploring the world of jQuery animation and background colors with Animate()

I'm currently attempting to implement a basic pulse effect by utilizing JQuery to modify the background color. However, I am facing issues with animating the backgroundColor property. function show_user(dnid) { /* dnid represents the HTML ID of a ...

Having trouble with the parent folder functionality in JavaScript?

I am facing a challenge with my website's structure as I have an old setup that needs to be updated. http://localhost/enc/pdfs/ : This directory contains some html files that are uploaded via ajax to be displayed on a tabbed div using: var Tabs ...

Is there a way to iterate through indexed variables in javascript?

After receiving an array of data from a JQuery .ajax function, I noticed that the fields in the array are named and numbered like part1, part2, part3, etc. I attempted to loop through this data using the code below, but unfortunately, it resulted in NaN: ...

ESLint is not performing linting even though the server is operational

I found a frontend template online and successfully installed all the packages using yarn. However, although I have an .eslint.json file in place and the ESLint extension is installed in Visual Studio Code, I am not seeing any linting errors. Below is the ...

Tips on coding javascript within an MVC4 C# environment

I am currently working with MVC 4 and facing an issue where I have the same action name for multiple views. This makes it difficult to write JavaScript code in all pages individually. Can I simply write the JavaScript in the C# action result instead? I at ...

What is the best way to create a fresh revision with every build in Vue.js?

Currently, I am utilizing vue cli along with pwa (workbox). Upon building the project, Vue automatically generates a file called: precache-manifest.882c44d211b70f8989278935.js. Within this file, there are entries for revision and url: { "revision": ...

The TypeScript error occurs when trying to set the state of a component: The argument 'X' cannot be assigned to the parameter of type '() => void'

When I attempt to call setState, I encounter a TypeScript error. Here is the code snippet causing the issue: updateRequests(requests: any, cb:Function|null = null) { this.setState( { requests: { ...this.state.requests, ...

Navigating through the content of slots within recurring slots in a subcomponent in Vue.js

I am encountering an issue with a child component, where each row in an object is rendered inside a div with a specific slot. I need to pass data from the parent for each of these elements. I've been attempting to iterate through every element of the ...

Tips on how to interact with a hyperlink in Python using a Selenium driver even when the content within the anchor tag is unknown

Utilizing a combination of selenium, phantomJS, and scrapy to scrape javascript content has proven to be an effective method. However, I am encountering an issue where I need to click on a link within a table after the javascript content has loaded. The ch ...

When using NodeJS with expressJS, remember that req.body can only retrieve one variable at a

I'm having trouble with my login and signup pages. The login page is working correctly, but the signup page is only transferring the password for some reason. App.JS: var express = require("express"); var app = express(); var bodyParser = require("bo ...

Is it possible to capture and generate an AxiosPromise inside a function?

I am looking to make a change in a function that currently returns an AxiosPromise. Here is the existing code: example(){ return api.get(url); } The api.get call returns an object of type AxiosPromise<any>. I would like to modify this function so ...

"Vanishing act: The mysterious disappearance of an empty JSON

After defining a JSON object and posting it to the backend (Node.js), there appears to be an issue. var imj = {}; imj.images = []; $.post("/image/uploadImages", imj, function(feedback){ ..... Unfortunately, when the backend received the data, the "images ...