Giter VIP home page Giter VIP 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.

== Contributing ==

npm install -g karma karma-cli karma-jasmine karma-chrome-launcher

Then from root directory :

./scripts/buildScalyr.js
./scripts/startJsTester

angular's People

Contributors

czerwingithub avatar mtorromeo avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

angular's Issues

$location.search() with parameters

hi
i need send parameters to $location.search() like bellow

key='data';

params_get_from_url = $location.search().key;

should change key dynamically change $location.search results but not work...

please help me.

unshift item in array

nice lib, working perfect when i push items to array, but when unshift it's working incorrectly
it is necessary to reevaluate all other items

maybe u have thoughts how to do it?

It doesn't work in IE 11

It works well on Chrome and firefox, but not in IE. It just doesn't work. Are you gonna fix it? It would be absolutely awesome!

How to force update?

I have a grid with dynamic columns that uses sly-repeat to repeat the items. I have the attribute directive slyEvaluateOnlyWhen pointing to the array of columns, and everytime we add/remove a column, it updates properly.

The problem comes when I want to add/delete items to this grid. If I delete the initial items, it's ok, but if I add items and then I delete them, the sly-repeat just empty the object of that item, but not delete it from the grid items array.

How can I force to update the repeat?

Implementation

Hello There:

First of all thank you for sharing your directives, that is very exciting stuff as my project needs some serious optimizations and Scalyr seems very promising. Though upon integration I am running through some issues such as:

ReferenceError: lhs is not defined
    at compile (http://127.0.0.1:9000/scalyr.js:579:15)
    at invokeLinkFn (http://127.0.0.1:9000/lib/angular/angular.js:8642:9)
    at nodeLinkFn (http://127.0.0.1:9000/lib/angular/angular.js:8142:11)
    at compositeLinkFn (http://127.0.0.1:9000/lib/angular/angular.js:7534:13)
    at nodeLinkFn (http://127.0.0.1:9000/lib/angular/angular.js:8137:24)
    at compositeLinkFn (http://127.0.0.1:9000/lib/angular/angular.js:7534:13)
    at publicLinkFn (http://127.0.0.1:9000/lib/angular/angular.js:7409:30)
    at compile (http://127.0.0.1:9000/lib/angular-ui-router/release/angular-ui-router.js:4026:9)
    at invokeLinkFn (http://127.0.0.1:9000/lib/angular/angular.js:8642:9)
    at nodeLinkFn (http://127.0.0.1:9000/lib/angular/angular.js:8142:11) <!-- slyRepeat: (groupName, groupData) in editSelection -->

I have added the script to the root folder as well as the folders that it came with and added 'sly' to my module dependencies, but is there anything else I am supposed to pass as a dependency to get the lhs error to disappear?

Thank you for the help and sorry for the burden.

Extra trailing commas stop closure-compiler

Don't want to make PR since this file is built by script (?) and real PR will take digging deeper.

Here's the patch:

--- a/scalyr.js 2016-03-16 10:40:08.035063271 +0300
+++ b/scalyr.js 2016-03-16 10:38:26.000000000 +0300
@@ -421,9 +421,9 @@
             return isNull(alwaysEvaluateString) || 
                    !(isStringNonempty(watchExpression) && (watchExpression.indexOf(alwaysEvaluateString) >= 0));
           }, true /* Evaluate any newly added watchers when they are added */);
-        },
+        }
       };
-    },
+    }
   };
 }])
 /**
@@ -441,7 +441,7 @@
   return {
     restrict: 'A',
     link: function(scope, element, attrs) {
-    },
+    }
   };
 })
 /**
@@ -480,7 +480,7 @@
     link: function slyShowLink(scope, element, attr) {
       scope.$watch(attr.slyShow, function ngSlyShowAction(value){
         $animate[toBoolean(value) ? 'removeClass' : 'addClass'](element, 'ng-hide');
-      }, false, 'slyShow'); },
+      }, false, 'slyShow'); }
   };
 }])
 /**
@@ -508,9 +508,9 @@
               return false;
             return true;
           });
-        },
+        }
       };
-    },
+    }
   };
 });

@@ -617,7 +617,7 @@
               // Need to add in an element for each new item in the collection.
               var newElement = {
                   scope: $scope.$new(),
-                  isActiveForRepeat: true,
+                  isActiveForRepeat: true
               };

               gateWatchersForScope(newElement);

Perfomance 2x worse than Angular 1.6.4

I have a 14k array, and bad perfomance with angular 1.6.4, but this method has 2x slower page rendereing time.
<md-card ng-repeat="photo in photos" ng-show="infiniteIndex>$index" class="flex-item">
VS
<md-card sly-repeat="photo in photos" sly-show="infiniteIndex>$index" sly-prevent-evaluation-when-hidden class="flex-item">

AngularJS 1.5.3

Why is there a creation of many workers with AngularJS? Could it be memory-hungry and causing loss of performance with long lists?

Thanks

Scalyr breaks angular ui tooltips

Angular 1.2.11 (same problem with older versions)
Angular UI Bootstrap 0.10.0 (same problem with older versions)

If you are using scalyr and angular ui tooltips you won't see a tooltip anymore if you have a tooltip-delay of 0. The tooltip should actually be shown, but it is not interpolated in the digest cycle. If you trigger another digest cycle while hovering over an element with a tooltip, the tooltip will be rendered, but has the wrong position.
As a workaround to render the tooltips you can set the tooltip-delay to 1ms or create an additional directive for the attribute tootltip and create an eventlistener on mouseenter to trigger the digest cycle, but this does not solve the problem with the wrong positioning.

bower.json

Could you please add your package to bower?

Iterate over map

Hello, is there any possibility to add maps support as follow

sly-repeat="(key, product) in products"

Best regards,
Adam

Tag version 1.0.1 for bower

Hi there,

can you please tag the latest commit with "1.0.1" so the tool bower recognizes the new version when somebody uses this github repository as source for sly in bower?

scajyr is leaking scopePrototype

First thanks for your nice work.

When using scalyr/angular in mocha, mocha reports global leak detected: scopePrototype

And indeed, l. 722, scalyr/angular is leaking a global variable "scopePrototype"

Could this be fixed ? I think a simple var would do it but I'm not 100% sure since we're dealing with complex Angular code.

equals is not defined

Using Angular 1.2.1 I get the following error:

ReferenceError: equals is not defined
    at Scope.gatedScopeDigest [as $digestGated] (http://localhost:7778/bower_components/angular-scalyr-optimization/scalyr.js:787:25)
    at Object.<anonymous> (http://localhost:7778/bower_components/angular-scalyr-optimization/scalyr.js:887:20)
    at Scope.$get.Scope.$digest [as $originalDigest] (http://localhost:7778/bower_components/angular/angular.js:11436:47)
    at Scope.$rootScope.$digest (http://localhost:7778/scripts/app.js:586:15)
    at Scope.$get.Scope.$apply (http://localhost:7778/bower_components/angular/angular.js:11682:24)
    at HTMLButtonElement.<anonymous> (http://localhost:7778/bower_components/angular/angular.js:17531:21)
    at HTMLButtonElement.b.event.dispatch (http://localhost:7778/bower_components/jquery/jquery.min.js:3:28337)
    at HTMLButtonElement.b.event.add.v.handle (http://localhost:7778/bower_components/jquery/jquery.min.js:3:25042) angular.js:9101

Maybe angular.equals or areEqual in line 175 was meant?

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.