Git Product home page Git Product logo

angular's Introduction

Angular Directives by Scalyr

This is the source code for the optimization directives Scalyr created to improve the responsiveness of its user interface, as discussed in the blog post Optimizing AngularJS: 1200ms to 35ms.

These directives are meant to demonstrate the optimization techniques discussed in the blog post. The directives were really only meant for internal use, but since there was sufficient interest from readers, we are publishing the source. Unfortunately, we cannot make maintaining this library a high priority. We will push bug fixes and accept pull requests from other developers, but beyond that, the source is provided as is. We expect this source will act more as a starting point for other developers rather than as a complete standalone Javascript library.

Also note, because some of the optimization techniques rely on non-public AngularJS variables and methods, these directives may not work for all versions of AngularJS. The current tests validate them against 1.2.1.

Furthermore, the directives were built with particular use cases in mind so they may not have all of the features you would expect. For example, our repeat directive 'slyRepeat' does not support animations and other features that 'ngRepeat' does.

The scalyr.js file contains the Javascript bundle required to use the directives. More information for each directive can be found in the src/js/directives directory. Here is a brief description of what is included:

sly
NameDescription
slyEvaluateOnlyWhen An attribute directive that prevents updating / evaluating all bindings and expressions for the current element and its children unless the object referenced by the attribute's value changes. It currently assumes the expression contained in the attribute value evaluates to an object and detects changes only by a change in object reference.
slyAlwaysEvaluate An attribute directive that can only be used in conjunction with the slyEvaluateOnlyWhen directive. This directive will ensure that any expression that is being watched will always be evaluated if it contains the string specified in the attribute value (i.e., it will ignore whether or not the slyEvaluateOnlyWhen expression has changed.) This is useful when you wish to check some expressions all the time. Note, this only works if the directives register a string watch expression so this may or may not work for some directives depending on their implementation.
slyPreventEvaluationWhenHidden An attribute directive that will only evaluate the bindings and expressions for the current element and its children if the current element is not hidden (detected by the element having the 'ng-hide' CSS class.)
slyShow An attribute directive that Will hide the element if the expression specified in the atttribute value evaluates to false. Uses the CSS class 'ng-hide' to hide the element. This is almost exactly the same as ngShow, but it has the advantage that it works better with slyPreventEvaluationWhenHidden by guaranteeing it show expression is always evaluated regardless of the effects of slyPreventEvaluationWhenHidden.
slyRepeat An attribute directive that is a modified version of the ngRepeat directive. It is meant to be more efficient for creating and recreating large lists of elements. In particular, it has an optimization that will prevent DOM elements from being constantly created and destroyed as the number of the repeated elements change. It does this by not destroying DOM elements when they are no longer needed, but instead, just hiding them. This might not work for all use cases. Cavaets: The collection expression must evaluate to an array. Animators will not work. Track By does not work. Use at your own peril.

Please contact [email protected] for any questions or problems.

angular's People

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.