Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(221)

Side by Side Diff: third_party/polymer/v1_0/find_unused_elements.py

Issue 2224003003: Vulcanize MD History to improve page-load performance (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « docs/vulcanize.md ('k') | third_party/polymer/v1_0/reproduce.sh » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 #!/usr/bin/python2 1 #!/usr/bin/python2
2 2
3 # Copyright 2016 The Chromium Authors. All rights reserved. 3 # Copyright 2016 The Chromium Authors. All rights reserved.
4 # Use of this source code is governed by a BSD-style license that can be 4 # Use of this source code is governed by a BSD-style license that can be
5 # found in the LICENSE file. 5 # found in the LICENSE file.
6 6
7 """Identifies Polymer elements that downloaded but not used by Chrome. 7 """Identifies Polymer elements that downloaded but not used by Chrome.
8 8
9 Only finds "first-order" unused elements; re-run after removing unused elements 9 Only finds "first-order" unused elements; re-run after removing unused elements
10 to check if other elements have become unused. 10 to check if other elements have become unused.
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
129 # Ignore the element's own files. 129 # Ignore the element's own files.
130 if dirpath.startswith(os.path.join( 130 if dirpath.startswith(os.path.join(
131 self.__COMPONENTS_DIR, element_dir)): 131 self.__COMPONENTS_DIR, element_dir)):
132 continue 132 continue
133 133
134 for filename in filenames: 134 for filename in filenames:
135 if not filename.endswith('.html') and not filename.endswith('.js'): 135 if not filename.endswith('.html') and not filename.endswith('.js'):
136 continue 136 continue
137 137
138 # Skip generated files that may include the element source. 138 # Skip generated files that may include the element source.
139 if filename in ('crisper.js', 'vulcanized.html'): 139 if filename in ('crisper.js', 'vulcanized.html',
140 'app.crisper.js', 'app.vulcanized.html'):
140 continue 141 continue
141 142
142 with open(os.path.join(dirpath, filename)) as f: 143 with open(os.path.join(dirpath, filename)) as f:
143 text = f.read() 144 text = f.read()
144 if not re.search('/%s/' % element_dir, text): 145 if not re.search('/%s/' % element_dir, text):
145 continue 146 continue
146 147
147 # Check the file again, ignoring comments (e.g. example imports and 148 # Check the file again, ignoring comments (e.g. example imports and
148 # scripts). 149 # scripts).
149 if re.search('/%s' % element_dir, 150 if re.search('/%s' % element_dir,
150 self.__StripComments( 151 self.__StripComments(
151 os.path.join(dirpath, filename))): 152 os.path.join(dirpath, filename))):
152 return True 153 return True
153 return False 154 return False
154 155
155 156
156 if __name__ == '__main__': 157 if __name__ == '__main__':
157 UnusedElementsDetector().Run() 158 UnusedElementsDetector().Run()
OLDNEW
« no previous file with comments | « docs/vulcanize.md ('k') | third_party/polymer/v1_0/reproduce.sh » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698