The script I'm about to share [r98] consists of loading an XML file loaded with mapping data. In this specific example, nodes with 'W' represent a wall. Once the XML file loads via AJAX it stores the nodes in an array.
Screenshot Map Editor
As you can see in this screenshot. The W represents the walls. H represents hollow spaces. S represents where the 8Direction will start.
The main loop destroys every wall block every tick. Then tests the X and Y limits of the viewport based off the scrollx and scrolly, and window height and width. If the conditions are met, the wall block is rendered. Otherwise it is ignored.
The overall size of this map (XML) is 50x50 nodes. Thats 2500 array index. With 32px tiles, this comes out to a 1600x1600 px map. Since performance degrades sharply at 1000 objects (if not before), rendering 2500 objects is a big no-no. This script allows you to only render what is needed.