Giới thiệu 5 Tips để debug Drupal front-end với Chrome DevTools

Giới thiệu 5 Tips để debug Drupal front-end với Chrome DevTools

5 of my favourite keyboard shortcuts in Chrome DevTools. I used them all the time to find bugs in JS, HTML and CSS

Giới thiệu 5 Tips để debug Drupal front-end với Chrome DevTools

1. CMD + ALT + F.  (Windows/Linux: CTRL + SHIFT + F)

A global search. Search in every asset HTML,CSS and JS.  Useful when you want to check if the browser is loading the changes you are doing, or to find something in the JavaScript code to place a breakpoint. Specially useful in production, when JavaScript files are aggregated, don't try to find the code manually. Use the global search.

alt_cmd.gif

2. CMD + Z (Windows/Linux: CTRL + Z)

Yes, the traditional 'undo' command. Did you know you can undo the CSS changes in DevTools?

ctrl_z.gif

3. CMD + S (Windows/Linux: CTRL + S)

Edit the JavaScript files inside DevTools (Source Tab). Then save the changes (CMD + S) . You will see in the console "Recompilation and update succeeded." and the background color will change.  This trick is not very useful alone. But you can use it while debugging with breakpoints.  This tip is really useful to debug on-the-fly in production sites.

breakpoint.gif

4. ALT + Click  (Windows/Linux: CTRL + ALT + Click)

This trick is awesome for severe cases of HTML divitis. Press ALT and click at the same time on the arrow, it will expand all their children.

alt_expand.gif

5. debugger;

This is not a keyboard shortcut. It's a statement defined ECMAScript 5, so it works in all modern browsers. Place the string debugger in your JavaScript code, and it will have the same effect than a breakpoint, halting JavaScript execution and opening the browser's debugger.

Bạn thấy bài viết này như thế nào?: 
No votes yet
Ảnh của Khanh Hoang

Khanh Hoang - Kenn

Kenn is a user experience designer and front end developer who enjoys creating beautiful and usable web and mobile experiences.

Advertisement

 

jobsora

Dich vu khu trung tphcm

Dich vu diet chuot tphcm

Dich vu diet con trung

Quảng Cáo Bài Viết

 
9 lý do “ép” iPad 3 phải xuất hiện vào đầu năm 2012

9 lý do “ép” iPad 3 phải xuất hiện vào đầu năm 2012

Theo một số nhà phân tích, Apple sẽ phải cho iPad 3 ra mắt vào quý 1 năm 2012 để có thể tiếp tục chiếm lĩnh thị trường máy tính bảng.

Create Awesome Cover Photo For Facebook Timeline Profile

Create Awesome Cover Photo For Facebook Timeline Profile

Facebook Timeline is one of the newest feature launched by Facebook recently with lots of new changes, Facebook cover photo is one of them.

Sending Drupal Webform Results to Different Email Addresses

Gửi email đến Email Addresses khác bằng Drupal Webform

One of our students is using Drupal's Webform module for their site's contact form.

Công ty diệt chuột T&C

 

Diet con trung