Exploring the debugger statement functionality within Vue 2's production code

How can I check if a user has devtools open in my Vue 2 webapp? I am using @vue/cli 5.0.8 with the default configuration for creating and building the app.

I came across this code snippet that might work -

const minimalUserResponseInMilliseconds = 100;
const before = Date.now();
debugger;
const after = Date.now();
if (after - before > minimalUserResponseInMilliseconds) {
  //Action
}

The issue I'm facing is that the default Vue build for production removes the debugger statement from the code.
Is there a way to keep this specific debugger keyword? Or prevent all debugger statements from being removed?

I attempted to add the following to my Vue.config, but the debugger statement was still stripped out

configureWebpack: {
  optimization: {
    minimizer: [
      new TerserPlugin({
        terserOptions: {
          compress: {
            drop_debugger: false // For checking if user opened devtools

Any assistance would be greatly appreciated, thank you!

Answer №1

Consider utilizing the properties "outHeight, outWidth, innerHeight, innerWidth" to fulfill your requirements.

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

Sliding through transitions in VueJS

I'm struggling with a form that has three steps where each step should transition from side to side on click of 'prev'/'next'. The issue I'm facing is that the transitions aren't being applied correctly after a direction ...

Tips for positioning the overlay to match the icon list when hovering- JavaScript/Cascading Style Sheets (CSS)

My challenge involves a list of <li>'s accompanied by an icon that, when hovered over, displays an overlay containing information about the 'test'. The setup looks something like this: test1 test2 test3 and so forth.... Here' ...

Utilizing custom filters to navigate through nested ng-repeats

My goal is to achieve a specific behavior by using custom filters. I am working on creating a unified search bar that will display entire group names with all failing students, as well as group names with only the matching students. If you want to see the ...

Error in ReactJs production code: ReferenceError - the process is undefined

Having some trouble with my ReactJs production code not recognizing environment variables. The error message reads: Uncaught ReferenceError: process is not defined <anonymous> webpack://testProject/./src/agent.js?:9 js http://localhost:8080/s ...

How do three buttons display identical content?

I have three buttons on my website, each with its own unique content that should display in a modal when clicked. However, I am experiencing an issue where regardless of which button I click, the same content from the last button added is displayed in the ...

Troubleshooting the 'App Already Bootstrapped with this Element' Error in AngularJS

When I try to load my AngularJS app, I encounter the following error: Uncaught Error: [ng:btstrpd] App Already Bootstrapped with this Element '<html lang="en" ng-app="app" class="ng-scope">' I have only placed ng-app once in the html elem ...

Converting a grayscale image matrix into an image using Node.js

I need help displaying an 8-bit grayscale image matrix (values between 0 and 255) from a C program on a website. Do I need to convert the image within the C program before displaying it? What is the best way to achieve this? ...

Routing WebSocket connections with Node.js

Currently, I am in the process of developing a chat application for my company which will run on node js with websocket (ws). The app is designed to cater to various departments within the organization, each with its own set of users. My goal is to ensure ...

Getting the ID name from a select tag with JavaScript - A quick guide!

Can you help me retrieve the id name using JavaScript when a selection is made in a select tag? I have tried running this code, but it only alerts undefined. For instance, if I select bbb in the select tag, I should be alerted with 2 Any suggestions on ...

Insert a fresh row into the gridview using JavaScript

I am working with a grid view where I dynamically add new rows using JavaScript. Each row in the grid view contains an image (addButton), which triggers a specific JavaScript function when clicked. function AddNewRecord(e) { debugger; var hfFirst ...

What is the best way to integrate JavaScript into an Express Handlebars template using partials?

In my current project, I have utilized the following handlebars template (located under views/layouts/main.handlebars): <!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>{{title}}</title> ...

Assign properties to a component from an object

I'm working on connecting React Components to Objects by passing imported Components as Props. const [showComponent, setShowComponent] = useState([ { cId: 1, componentName: <ContactDialogAddresses />, title: 'Address', render: true ...

I created a custom function that combines two arrays into one, but I am encountering an error stating "Unable to access properties of undefined."

I am facing a challenge with combining two arrays into one new array that merges the objects of each array together. While I know how to merge two arrays into a single array, I am struggling to combine the actual objects into a brand new object within that ...

How can you show a green check mark next to an input field in AngularJS after inputting valid data?

I am diving into the world of AngularJS and Angular Material with my web application. As a beginner in AngularJS and Angular Material, I need some help. My current task is to display a green checkmark next to an input field only when valid data is entere ...

The canvas animation displays a sequence of previous frames

My challenge lies in rotating an object on the canvas, as all previous frames continue to be displayed. I suspect the issue is related to this particular line of code: setTimeout(this.rotate.bind(this), 1000 / 10); Is there a way to have only the current ...

Using a template element for looping over an array with conditional rendering

I'm facing a challenge with conditionally rendering elements in a list using Petite-Vue. When I try to place a <li> tag with a v-if attribute inside a <template> tag with a v-for attribute, an error is generated: Uncaught (in promise) Ty ...

The props are not being pushed as expected when using this.$router.push

I am currently in the process of navigating from one webpage to another and attempting to pass along properties to the new page component. Take a look at how I have set up my router.push below: this.$router.push({ name: 'settings', params: { ...

Iterate through JSON data and access values based on keys using a $.each loop

I have retrieved JSON data from the controller using AJAX and now I want to access this data. The data is in the form of a list of objects (array) with key-value pairs, so I am planning to use .each() function to go through all the data. The array looks li ...

Controlling the Vuetify Navigation drawer from a separate component

Within my App.vue component, I have a Navigation Drawer menu containing main items and some subitems. These subitems are meant to be displayed only after a specific event, such as a button click on the child component's page (when the variable totalRe ...

Trigger the next button click event using jQuery

Is it possible to implement a slideshow on my website where clicking a button displays the relevant slide? My goal is to incorporate a timer that will automatically click the next button after 3 seconds, enabling the slideshow to transition automatically. ...