Angular 1.2 enables debugInfoEnabled feature

With the release of Angular 1.3, a new method called debugInfoEnabled() was introduced which can significantly improve performance when set to false in the application config function:

myApp.config(['$compileProvider', function ($compileProvider) {
    $compileProvider.debugInfoEnabled(false);
}]);

Unfortunately, Angular 1.3 discontinued support for IE8. This presents an issue for applications like mine that must run on IE8. As a result, I have had to stick with version 1.2.

If you're facing the same dilemma and need to replicate the functionality of debugInfoEnabled() in Angular 1.2, here are some aspects you can focus on:

  • Avoid creating ng-scope/ng-isolated-scope CSS classes while generating new scopes
  • Omit attaching binding data and ng-class CSS class to elements using ngBind, ngBindHtml or {{...}} interpolations

One potential solution could involve forking the angularjs repository and backporting the desired feature to version 1.2. This would require maintaining updates from the original source.

If you have any insights or suggestions, they would be much appreciated.

Answer №1

In order to prevent the default behavior, utilize the underlying DOM setAttribute method. The plunker in the previous response has been modified:

http://plnkr.co/edit/cMar0d9IbalFxDA6AU3e?p=preview

To achieve the following actions:

  • Duplicate the DOM setAttribute prototype method
  • Rewrite it with a validation for ng debug attributes
  • Provide a false return for ng debug attributes
  • Return normally otherwise

Implement by doing the following:

/* Clone the original */
Element.prototype.ngSetAttribute = Element.prototype.setAttribute;

/* Overwrite the API */
Element.prototype.setAttribute = function(attr, val) {
/* Define ng debug attributes */ 
var ngAttributes = {"ng-binding": true, "ng-scope":true,"ng-class":true,"ng-isolated-scope":true};

console.log([attr,val]);

/* Block ng debug attributes; call the clone otherwise */
if (ngAttributes[attr]) 
  return false; 
else if (JSON.stringify(ngAttributes).match(attr) )
  return false;
else
  return this.ngSetAttribute(attr, val);
}

For IE8 compatibility, substitute Element for HTMLElement.

Additional Resources

Answer №2

If you want to turn off logging, you can use the code $logProvider.debugEnabled(true); in your angular configuration settings. To see the effects of the debugEnabled setting, make sure you are using the $log provider when logging.

Example Code:

var app = angular.module('myApp', []);

app.config(function($logProvider){
  $logProvider.debugEnabled(false);
});

app.controller('MainCtrl', function($scope, $log ) {
  $scope.name = 'Hello World!';
  $scope.testModel = {name: "test"};
  //console.log('This will show log even if debugging is disable');
  $log.debug('TEST Log');
});

Here is a Fiddle for reference.

I hope this explanation helps you with your question.

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

When attempting to click on my subtopics using jQuery, they do not appear as expected

$(document).ready(function () { $("#subTopics").hide(); $("#mainTopics").click(function () { $("#subTopics").show("slow"); }); }); body { margin: 0; } li, a{ text-decoration: none; list-style-type: none; text-d ...

What sets apart the <script> tag with a type attribute from the standard <script> tag in HTML?

Similar Question: Is it necessary to include type=“text/javascript” in SCRIPT tags? While working on my HTML project, I noticed that the JavaScript code within script tags is evaluated even if the type attribute is not explicitly set to "j ...

What could be the reason why my sorting function is not functioning properly?

I am currently in a state of questioning everything I thought I knew. > [ 37, 4, 3, 1, 3, 10, 8, 29, 9, 13, 19, 12, 11, 14, 20, 22, 22, 27, 28, 33, 34 ].sort((a, b) => a > b) [19, 34, 3, 1, 3, 10, 8, 29, 9, 13, 4, 12, 11, 14, 20, 22, 22, 27, 28, ...

Leveraging jsPDF and html2canvas in conjunction with ES6

I am currently experimenting with jsPDF and html2canvas in an ES6 environment. While I have successfully imported html2canvas and jsPDF, I encountered an error when using the addHTML function. Interestingly, when I commented out the addHTML code, the PDF ...

Having difficulty retrieving objects within a foreach loop of object keys that do not meet the criteria of the string.prototype.replace method

Currently, I am working on looping over objects within a key:value array in JavaScript to use the string.prototype.replace method for paths to JS files in GulpJS concat tasks. The objective is to generate a list of paths that GULP can utilize, but they re ...

Issue with filtering tasks in a Task Tracker application

Hey there! I'm new to JavaScript and I've been working on a todo app. Everything seems to be running smoothly except for the filter function, which I just can't seem to get working no matter what I try. I previously had a similar app with ma ...

Utilizing an object's attribute to reference an image for a source

I am encountering an issue trying to display an image from the video object's image attribute on the screen when my program runs. The problem lies in the fact that there is no file named 'videoObj1.image', which causes a source error. I am e ...

Angular's $http service fetches data successfully, however, it fails to update the scope with the

Within the realm of AngularJS, I've implemented a factory as follows: .factory('Users', function($http) { var users = []; return { getUsers: function() { return $http.get("data.json") .then(function(response) { ...

What's the best way to update the value of a TextInput field?

Previously, I was updating the text input using local state. Here's an example: state = {name: ''} ... <AddEditFormInputs onChangeText={name => this.setState({ name })} textStateValue ...

How to invoke a function from a different ng-app in AngularJS

I have 2 ng-app block on the same page. One is for listing items and the other one is for inserting them. I am trying to call the listing function after I finish inserting, but so far I haven't been successful in doing so. I have researched how to cal ...

Dynamically loading Ember templates with asynchronous requests

I need a way to dynamically load HTML content from another file using the code below: App.MainView = Ember.View.extend({ template:function(){ $.ajax({ url: 'views/main.html', dataType: 'text', async: false, ...

Even though I have successfully stored a key value pair in LocalStorage using JSON stringify and setItem, the data does not persist after the page is refreshed

I recently developed a Todo application that runs smoothly, except for one crucial issue - the localStorage data does not persist after refreshing the page. Initially, the localStorage operations functioned properly when there were fewer event handlers in ...

Problem encountered after eliminating hash signs from routing in Angular-UI-Router

I successfully removed (#) hashbangs using $locationProvider.html5Mode(true) in ui-router. I also set the base URL as <base href="/public/">. When attempting to access localhost:59940/public/#/home, the # is removed from the URL and it appears as lo ...

The onChange functionality of the Formik Field API is not compatible with a child component

I am currently facing an issue with validating a material-ui-dropzone component within the Formik Field API as a child component. When I try to upload a file, I encounter the following error: TypeError: can't access property "type", target is undefine ...

Is there a way to generate buttons for values that are stored within an array, which is nested inside another array?

I am currently facing difficulties in creating buttons for values within an array, which are also nested inside another array. As an example: let numbers = [{"allNum": ["0", "1", "2", "3","4"]}, { ...

Leveraging callback functions for dynamically updating a JSON structure

Recently, I've been working on a db_functions.js file that includes several functions designed to interact with a database. Here's an excerpt from the script: function getUsers(client, fn){ //var directors = {}; client.keys('*' ...

Introducing a content height offset to create a smooth slide-up animation on hover

How can I offset a block with a title and description above a picture by the height of the description content? See the example picture below: https://i.sstatic.net/DzcMo.png The goal is to have both titles visible by default, but when hovering over the ...

Updating the default value in Angular select directive

I am facing an issue with setting the default value of a select box from a controller value. Here is my controller setup: controller.item = {name: "bar1", value: 1} controller.items = [{name: "bar0", value: 0}, {name: "bar1", value: 1}] Below is my HTML ...

Activate the "order evaluation" trigger on the checkout page in Woocommerce

I have implemented the Woocommerce Advanced Shipping plugin created by Jeroen Sormani for managing shipping methods, along with the WooCommerce Pay for Payment plugin developed by Karolína Vyskočilová to add a fixed €5 fee to the "cash on delivery" pa ...

Use JavaScript to illuminate individual words on a webpage in sequence

Is there an effective method to sequentially highlight each word on a web page? I'm thinking of breaking the words into an array and iterating through them, but I'm not sure what the best approach would be. I have experience with string replacem ...