Preheat the oven to 375 degrees F (190 degrees C).
Set the spinach in a colander to drain while you prepare the remaining ingredients, then place it in the center of a large, sturdy dish towel. Squeeze out as much moisture as you can. (If you wash the towel shortly after, the color won't stain)
Heat a large pan over medium heat. Melt the butter, and pour off and reserve about 5 tablespoons. Add the onion to the skillet and cook until soft but not brown, about 5 minutes. Transfer to a bowl with the squeezed spinach, and add the ricotta, eggs, feta, dill (if using), lemon juice, salt, and pepper.
Brush a 9-by-13-inch (23-by-33-centimeter) baking pan with some of the reserved melted butter. Lay one sheet of phyllo in the pan so it covers the bottom halfway, leaving an overhang on 3 sides. Lay the second sheet across the other half of the pan, overlapping the first and leaving an overhang on 3 sides; gently press the phyllo into the corners of the pan and brush with butter. Continue with another two sheets of phyllo right on top, layering them slightly overlapping to cover the bottom and up the sides (so far, you've used four sheets.) Add the spinach mixture and spread into an even layer; season again if necessary. Fold the sides of the phyllo over the top, brushing with butter, then fold the remaining two sheets of phyllo in half and layer on top, brushing each with the remaining butter.
Bake until the phyllo is cooked through, shiny, and golden brown, 40 to 45 minutes. Remove and let cool until just warm to the touch before cutting. Cut into 9 or 12 pieces and serve warm or at room temperature. Refrigerate any leftovers in an airtight container or up to 3 days.